/**
*  @file
* @description 公共组件注册文件
 */


import {
    Button, Table, Tree, Form, FormItem,
    Input, Menu, MenuItem, MenuItemGroup,
    Message, Dialog, Loading,
    Switch, Select, Option,
    Submenu, Result, Breadcrumb, BreadcrumbItem, MessageBox, TableColumn, Pagination
} from "element-ui"

import { confirm } from "uti/common"
// import MyConfirm from "com/MyConfirm"
// import Vue from "vue"    1
// const myConfirm = Vue.extend(MyConfirm)
import { myConfirm } from "com/MyConfirm/index.js"
import MyDialog from "com/Dialog"
import MyTable from "com/Table"

export default {
    install(Vue) {
        Vue.prototype.$myConfirm = myConfirm

        // Vue.component(MyConfirm.name, MyConfirm)

        // Vue.prototype.$myConfirm = (message, title = "提示") => {
        //     return new Promise((resolve, reject) => {
        //         const obj = new myConfirm({ propsData: { message, title } })

        //         /**
        //          * 取消
        //          *  */
        //         const cancel = () => {
        //             obj.$off('cancel', cancel)
        //             reject()
        //         }
        //         /**   2
        //         * 确认
        //          */
        //         const ok = () => {
        //             obj.$off('ok', ok)
        //             resolve(obj.close)
        //         }
        //         obj.$on('cancel', cancel)
        //         obj.$on('ok', ok)
        //         document.body.appendChild(obj.$mount().$el)
        //     })
        // }
        Vue.prototype.$mb = MessageBox,
            Vue.prototype.$confirm = confirm,
            Vue.prototype.$m = Message,
            [MyDialog, MyTable].forEach(item => Vue.component(item.name, item));
        [Button, Table, Tree, Form, FormItem, Input,
            Loading, Dialog, Switch, Select, Option,
            Menu, MenuItem, MenuItemGroup, Submenu, Result,
            Breadcrumb, BreadcrumbItem, TableColumn, Pagination

        ].forEach(item => Vue.use(item))
    }
}